#include "chapter_practice_10_2.h"
#include "chapter_practice_10_8.h"
#include <iostream>

void Practice10_2();
void Practice10_8();
void showAll(Item & item);

//int main()
//{
//	Practice10_8();
//	return 0;
//}

void Practice10_2()
{
	Person_practice_10_2 one;
	Person_practice_10_2 two("Smythecraft");
	Person_practice_10_2 three("Dimwiddy", "Sam");

	one.Show();
	two.FormalShow();
	three.Show();
	return;
}

void Practice10_8()
{
	using namespace std;
	MyList list;	//create an empty list
	char ch;
	int po;
	cout << "Please enter A to add a purchase order,\n"
		<< "P to process a PO, or Q to quit.\n";
	while (cin >> ch && toupper(ch) != 'Q')
	{
		while (cin.get() != '\n')
			continue;
		if (!isalpha(ch))
		{
			cout << '\a';
			continue;
		}
		switch (ch)
		{
		case'A':
		case'a':
			if (list.isfull())
			{
				cout << "The list is full" << endl;
			}
			else
			{
				cout << "Enter a PO number to add: ";
				cin >> po;
			}
			list.push(po);
			break;
		case'p':
		case'P':
			if (list.isempty())
				cout << "The list is empty" << endl;
			else 
			{
				list.pop(po);
				cout << "PO #" << po << " popped\n";
			}
			break;
		}
		cout << "Please enter A to add a purchase order,\n"
			<< "P to process a PO, or Q to quit.\n";
	}
	list.visit(showAll);
	cout << "bye!" << endl;
	return;
}

void showAll(Item & item)
{
	cout << item << endl;
}


